/**
 * 推荐菜品相关API
 */
import { api } from '@/utils/request'
import type { PaginatedResponse, RecommendedDish, DishQueryParams, ApiResponse } from '@/types/api'

/**
 * 获取推荐菜品列表
 */
export function getDishes(params?: DishQueryParams): Promise<PaginatedResponse<RecommendedDish>> {
  return api.get('/dishes', { params })
}

/**
 * 获取推荐菜品详情
 */
export function getDishById(id: number): Promise<ApiResponse<RecommendedDish>> {
  return api.get(`/dishes/${id}`)
}

/**
 * 添加推荐菜品（支持图片上传）
 */
export function addDish(
  locationId: number,
  data: FormData
): Promise<ApiResponse<RecommendedDish>> {
  return api.post(`/locations/${locationId}/dishes`, data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * 更新推荐菜品（支持图片上传）
 */
export function updateDish(
  locationId: number,
  dishId: number,
  data: FormData
): Promise<ApiResponse<RecommendedDish>> {
  return api.put(`/locations/${locationId}/dishes/${dishId}`, data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

/**
 * 删除推荐菜品
 */
export function deleteDish(locationId: number, dishId: number): Promise<ApiResponse<null>> {
  return api.delete(`/locations/${locationId}/dishes/${dishId}`)
}
